<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1 id="book">岛上书店</h1>
<input type="button" value="改名字" onclick="changeBookName()">
<p>
    <input type="text" name="seasons" value="春">
    <input type="text" name="seasons" value="夏">
    <input type="text" name="seasons" value="秋">
    <input type="text" name="seasons" value="冬">
</p>
<input type="button" value="相同name" onclick="getByName()">
<input type="button" value="相同input" onclick="getByTagName()">
<p id="res"></p>
<script type="text/javascript">
    function changeBookName() {
        //获取id元素并修改内容
        document.getElementById("book").innerHTML = "现象级畅销书"
    }
    
    function getByName() {
        //数组 相同name
        var seasons = document.getElementsByName("seasons");
        let str = "";
        for (let season of seasons) { //for - of 循环
            str += season.value +",";
        }
        document.getElementById("res").innerHTML = str;
    }
    
    function getByTagName() {
        //数组
        var seasons = document.getElementsByTagName("input");
        let str = "";
        for (let season of seasons) { //for - of 循环
            str += season.value +",";
        }
        document.getElementById("res").innerHTML = str;
    }

</script>
</body>
</html>